package algotithm.acwing.prefixadd.test796;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/20-10:33
 */
import java.io.*;
public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] num = reader.readLine().split(" ");
        int n = Integer.parseInt(num[0]);
        int m = Integer.parseInt(num[1]);
        int q = Integer.parseInt(num[2]);
        int[][] arr = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            String[] str = reader.readLine().split(" ");
            for (int j = 1; j <= m; j++) {
                arr[i][j] = Integer.parseInt(str[j-1]);
            }
        }

        int[][]s = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + arr[i][j];
            }
        }
        while (q-- > 0) {
            String[] sq = reader.readLine().split(" ");
            int x1 = Integer.parseInt(sq[0]);
            int y1 = Integer.parseInt(sq[1]);
            int x2 = Integer.parseInt(sq[2]);
            int y2 = Integer.parseInt(sq[3]);

            int res = s[x2][y2] - s[x2][y1-1] - s[x1-1][y2] + s[x1-1][y1-1];
            writer.write(res + "\n");

        }
        writer.flush();
        writer.close();
        reader.close();

    }

}
